// src/mixins/common.js
export default {
  data() {
    return { loading: false };
  },
  methods: {
    formatTime(ts) {
      const d = new Date(ts);
      const p = n => String(n).padStart(2, '0');
      return `${d.getFullYear()}-${p(d.getMonth()+1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
    },
    fetchStart() { this.loading = true; },
    fetchEnd() { this.loading = false; }
  },
  created() {
    // 组件创建时都会执行
    // console.log('[common mixin] in', this.$options.name);
  }
};